<?php
/**
 * Created by PhpStorm.
 * User: mf
 * Date: 2017/9/5
 * Time: 17:59
 */
namespace app\admin\controller;

use app\admin\logic\Shoppingcart as LogicShoppingcart;
use tool\Common;
use think\Request;

class Shoppingcart extends Base
{
    protected $shoppingcart;

    public function __construct(LogicShoppingcart $shoppingcart)
    {
        parent::__construct();
        $this->shoppingcart = $shoppingcart;
    }

    //添加商品到产品采购计划表
    public function addProductToPlanBuy()
    {
        $data = [
            'productID' => 1,
            'number' => 10,
            'price' => 2000.00,
            'totalPrice' => 20000.00
        ];
        //$data = Request::instance()->post();
        $shoppingcart = new LogicShoppingcart();
        $res = $shoppingcart->init($data)->addProductToPlanBuy();
        Common::json($res);
    }

    //查看我的(0购物车1议价中2确认)
    public function getShoppingcartList()
    {
        $data = [
            'status' => 0,
            'teamID' => 14
        ];
        //$data = Request::instance()->post();
        $planbuy = new LogicShoppingcart();
        $res = $planbuy->init($data)->getShoppingcartList();
        Common::json($res);
    }

    //订单之后的产品列表
    public function getContractProductList()
    {
        $data = [
            'status' => 4
        ];
        //$data = Request::instance()->post();
        $planbuy = new LogicShoppingcart();
        $res = $planbuy->init($data)->getContractProductList();
        Common::json($res);
    }

    //支队、总队点击议价按钮
    public function bargaining()
    {
        $data = [
            'cartID' => 14
        ];
        //$data = Request::instance()->post();
        $res = $this->shoppingcart->init($data)->bargaining();
        Common::json($res);
    }
    //商家、支队、总队修改订单信息
    public function revise()
    {
        $data = [
            'cartID' => 14,
            'number' => 5
        ];
        //$data = Request::instance()->post();
        $res = $this->shoppingcart->init($data)->revise();
        Common::json($res);
    }

    //支队、总队点击确认按钮
    public function confirm()
    {
        $data = [
            'cartID' => 14
        ];
        //$data = Request::instance()->post();
        $res = $this->shoppingcart->init($data)->confirm();
        Common::json($res);
    }

    //选择确认的订单生成合同
    public function createContract()
    {
        /*$data = [
            'cartID' => [
                1,22
            ]
        ];*/
        $data = Request::instance()->post();
        $res = $this->shoppingcart->init($data)->createContract();
        Common::json($res);
    }

    public function test()
    {
        $res = $this->shoppingcart->test();
        Common::json($res);
    }

    //商家发货按钮（针对一个合同）
    public function sendoutProduct()
    {
        $data = [
            'numberID' => 2017101916133113
        ];
        //$data = Request::instance()->post();
        $res = $this->shoppingcart->init($data)->sendoutProduct();
        Common::json($res);
    }

    //采购统计
    public function purchaseProuctList()
    {
        $data = [
            'teamID' => 12
        ];
        //$data = Request::instance()->post();
        $res = $this->shoppingcart->init($data)->purchaseProuctList();
        Common::json($res);
    }
}
